#version 130

uniform mat4 ModelMatrix;
uniform mat4 ViewMatrix;
uniform mat3 NormalMatrix;
uniform mat4 ProjectionMatrix;

uniform vec3 CameraPosition;
varying vec2 TexCoord;

//varying vec3 AmbientalLightIntensity;
varying vec3 position;
varying vec3 normal;
uniform vec3 LightPosition;
varying vec3 tangentSurface2Light;
varying vec3 tangentSurface2View;

attribute vec3 tangent;
varying mat3 bumpingMatrix;
//varying vec3 vectorTangent;

void main() {

	// the following three lines provide the same result

	//	gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
	//	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
	//	gl_Position = ftransform();

	TexCoord = gl_MultiTexCoord0.xy;


	
	normal = normalize(NormalMatrix * gl_Normal);
	vec3 t = normalize(NormalMatrix * tangent);
	vec3 b = cross(t, normal);
	
	//vectorTangent = t;

	bumpingMatrix = mat3(t.x, b.x, normal.x, t.y, b.y, normal.y, t.z, b.z, normal.z);

	position = vec3(gl_ModelViewMatrix * gl_Vertex); //get the position of the vertex after translation, rotation, scaling
	// posicion sin proyectar el vertice para obtener el elemento en su posicion
	gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * gl_Vertex;	//output position with projection

}

